package com.fitns.user.mapper.baseConfig;

import static com.fitns.user.mapper.baseConfig.TbVehicleMonitorDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import com.fitns.user.model.baseConfig.TbVehicleMonitor;

import java.util.List;
import javax.annotation.Generated;

import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.SqlBuilder;
import org.mybatis.dynamic.sql.delete.DeleteDSL;
import org.mybatis.dynamic.sql.delete.MyBatis3DeleteModelAdapter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.render.RenderingStrategy;
import org.mybatis.dynamic.sql.select.MyBatis3SelectModelAdapter;
import org.mybatis.dynamic.sql.select.QueryExpressionDSL;
import org.mybatis.dynamic.sql.select.SelectDSL;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.MyBatis3UpdateModelAdapter;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;

@Mapper
public interface TbVehicleMonitorMapper {
    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="record.id", before=false, resultType=Long.class)
    int insert(InsertStatementProvider<TbVehicleMonitor> insertStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("TbVehicleMonitorResult")
    TbVehicleMonitor selectOne(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="TbVehicleMonitorResult", value = {
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="plate_num", property="plateNum", jdbcType=JdbcType.VARCHAR),
        @Result(column="type", property="type", jdbcType=JdbcType.VARCHAR),
        @Result(column="organ_id", property="organId", jdbcType=JdbcType.BIGINT),
        @Result(column="road_id", property="roadId", jdbcType=JdbcType.BIGINT),
        @Result(column="gprs_status", property="gprsStatus", jdbcType=JdbcType.VARCHAR),
        @Result(column="work_status", property="workStatus", jdbcType=JdbcType.VARCHAR),
        @Result(column="speed", property="speed", jdbcType=JdbcType.REAL),
        @Result(column="direction", property="direction", jdbcType=JdbcType.VARCHAR),
        @Result(column="oil", property="oil", jdbcType=JdbcType.REAL),
        @Result(column="input_time", property="inputTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="lgitude", property="lgitude", jdbcType=JdbcType.VARCHAR),
        @Result(column="latitude", property="latitude", jdbcType=JdbcType.VARCHAR),
        @Result(column="video", property="video", jdbcType=JdbcType.VARCHAR),
        @Result(column="remark", property="remark", jdbcType=JdbcType.VARCHAR)
    })
    List<TbVehicleMonitor> selectMany(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<Long>> countByExample() {
        return SelectDSL.selectWithMapper(this::count, SqlBuilder.count())
                .from(tbVehicleMonitor);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default DeleteDSL<MyBatis3DeleteModelAdapter<Integer>> deleteByExample() {
        return DeleteDSL.deleteFromWithMapper(this::delete, tbVehicleMonitor);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int deleteByPrimaryKey(Long id_) {
        return DeleteDSL.deleteFromWithMapper(this::delete, tbVehicleMonitor)
                .where(id, isEqualTo(id_))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insert(TbVehicleMonitor record) {
        return insert(SqlBuilder.insert(record)
                .into(tbVehicleMonitor)
                .map(plateNum).toProperty("plateNum")
                .map(type).toProperty("type")
                .map(organId).toProperty("organId")
                .map(roadId).toProperty("roadId")
                .map(gprsStatus).toProperty("gprsStatus")
                .map(workStatus).toProperty("workStatus")
                .map(speed).toProperty("speed")
                .map(direction).toProperty("direction")
                .map(oil).toProperty("oil")
                .map(inputTime).toProperty("inputTime")
                .map(lgitude).toProperty("lgitude")
                .map(latitude).toProperty("latitude")
                .map(video).toProperty("video")
                .map(remark).toProperty("remark")
                .build()
                .render(RenderingStrategy.MYBATIS3));
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insertSelective(TbVehicleMonitor record) {
        return insert(SqlBuilder.insert(record)
                .into(tbVehicleMonitor)
                .map(plateNum).toPropertyWhenPresent("plateNum", record::getPlateNum)
                .map(type).toPropertyWhenPresent("type", record::getType)
                .map(organId).toPropertyWhenPresent("organId", record::getOrganId)
                .map(roadId).toPropertyWhenPresent("roadId", record::getRoadId)
                .map(gprsStatus).toPropertyWhenPresent("gprsStatus", record::getGprsStatus)
                .map(workStatus).toPropertyWhenPresent("workStatus", record::getWorkStatus)
                .map(speed).toPropertyWhenPresent("speed", record::getSpeed)
                .map(direction).toPropertyWhenPresent("direction", record::getDirection)
                .map(oil).toPropertyWhenPresent("oil", record::getOil)
                .map(inputTime).toPropertyWhenPresent("inputTime", record::getInputTime)
                .map(lgitude).toPropertyWhenPresent("lgitude", record::getLgitude)
                .map(latitude).toPropertyWhenPresent("latitude", record::getLatitude)
                .map(video).toPropertyWhenPresent("video", record::getVideo)
                .map(remark).toPropertyWhenPresent("remark", record::getRemark)
                .build()
                .render(RenderingStrategy.MYBATIS3));
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<TbVehicleMonitor>>> selectByExample() {
        return SelectDSL.selectWithMapper(this::selectMany, id, plateNum, type, organId, roadId, gprsStatus, workStatus, speed, direction, oil, inputTime, lgitude, latitude, video, remark)
                .from(tbVehicleMonitor);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<TbVehicleMonitor>>> selectDistinctByExample() {
        return SelectDSL.selectDistinctWithMapper(this::selectMany, id, plateNum, type, organId, roadId, gprsStatus, workStatus, speed, direction, oil, inputTime, lgitude, latitude, video, remark)
                .from(tbVehicleMonitor);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default TbVehicleMonitor selectByPrimaryKey(Long id_) {
        return SelectDSL.selectWithMapper(this::selectOne, id, plateNum, type, organId, roadId, gprsStatus, workStatus, speed, direction, oil, inputTime, lgitude, latitude, video, remark)
                .from(tbVehicleMonitor)
                .where(id, isEqualTo(id_))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>> updateByExample(TbVehicleMonitor record) {
        return UpdateDSL.updateWithMapper(this::update, tbVehicleMonitor)
                .set(plateNum).equalTo(record::getPlateNum)
                .set(type).equalTo(record::getType)
                .set(organId).equalTo(record::getOrganId)
                .set(roadId).equalTo(record::getRoadId)
                .set(gprsStatus).equalTo(record::getGprsStatus)
                .set(workStatus).equalTo(record::getWorkStatus)
                .set(speed).equalTo(record::getSpeed)
                .set(direction).equalTo(record::getDirection)
                .set(oil).equalTo(record::getOil)
                .set(inputTime).equalTo(record::getInputTime)
                .set(lgitude).equalTo(record::getLgitude)
                .set(latitude).equalTo(record::getLatitude)
                .set(video).equalTo(record::getVideo)
                .set(remark).equalTo(record::getRemark);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>> updateByExampleSelective(TbVehicleMonitor record) {
        return UpdateDSL.updateWithMapper(this::update, tbVehicleMonitor)
                .set(plateNum).equalToWhenPresent(record::getPlateNum)
                .set(type).equalToWhenPresent(record::getType)
                .set(organId).equalToWhenPresent(record::getOrganId)
                .set(roadId).equalToWhenPresent(record::getRoadId)
                .set(gprsStatus).equalToWhenPresent(record::getGprsStatus)
                .set(workStatus).equalToWhenPresent(record::getWorkStatus)
                .set(speed).equalToWhenPresent(record::getSpeed)
                .set(direction).equalToWhenPresent(record::getDirection)
                .set(oil).equalToWhenPresent(record::getOil)
                .set(inputTime).equalToWhenPresent(record::getInputTime)
                .set(lgitude).equalToWhenPresent(record::getLgitude)
                .set(latitude).equalToWhenPresent(record::getLatitude)
                .set(video).equalToWhenPresent(record::getVideo)
                .set(remark).equalToWhenPresent(record::getRemark);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int updateByPrimaryKey(TbVehicleMonitor record) {
        return UpdateDSL.updateWithMapper(this::update, tbVehicleMonitor)
                .set(plateNum).equalTo(record::getPlateNum)
                .set(type).equalTo(record::getType)
                .set(organId).equalTo(record::getOrganId)
                .set(roadId).equalTo(record::getRoadId)
                .set(gprsStatus).equalTo(record::getGprsStatus)
                .set(workStatus).equalTo(record::getWorkStatus)
                .set(speed).equalTo(record::getSpeed)
                .set(direction).equalTo(record::getDirection)
                .set(oil).equalTo(record::getOil)
                .set(inputTime).equalTo(record::getInputTime)
                .set(lgitude).equalTo(record::getLgitude)
                .set(latitude).equalTo(record::getLatitude)
                .set(video).equalTo(record::getVideo)
                .set(remark).equalTo(record::getRemark)
                .where(id, isEqualTo(record::getId))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int updateByPrimaryKeySelective(TbVehicleMonitor record) {
        return UpdateDSL.updateWithMapper(this::update, tbVehicleMonitor)
                .set(plateNum).equalToWhenPresent(record::getPlateNum)
                .set(type).equalToWhenPresent(record::getType)
                .set(organId).equalToWhenPresent(record::getOrganId)
                .set(roadId).equalToWhenPresent(record::getRoadId)
                .set(gprsStatus).equalToWhenPresent(record::getGprsStatus)
                .set(workStatus).equalToWhenPresent(record::getWorkStatus)
                .set(speed).equalToWhenPresent(record::getSpeed)
                .set(direction).equalToWhenPresent(record::getDirection)
                .set(oil).equalToWhenPresent(record::getOil)
                .set(inputTime).equalToWhenPresent(record::getInputTime)
                .set(lgitude).equalToWhenPresent(record::getLgitude)
                .set(latitude).equalToWhenPresent(record::getLatitude)
                .set(video).equalToWhenPresent(record::getVideo)
                .set(remark).equalToWhenPresent(record::getRemark)
                .where(id, isEqualTo(record::getId))
                .build()
                .execute();
    }
}